package it.com;

public class OperDemo {
    public static void main(String[] args) {
        int a = 10;
        a += 10;//a=a+10;
        System.out.println(a);

        //三元运算
        //判断89和100哪个数字大
        int num1 = 89;
        int num2 = 100;
        int max = (num1 > num2) ? num1 : num2;
        System.out.println("max = " + max);


        //求1-100之和
        int sum = 0;
        for (int i = 1; i <= 100; i++) {
            sum += i;
        }
        System.out.println(sum);


        //求1-100的奇数之和
        int sum1 = 0;
        for (int i = 1; i <= 100; i++) {
            if (i % 2 != 0) {
                sum1 += i;
            }
        }
        System.out.println("sum1 = " + sum1);

        //求1-100的偶数之和
        int sum2 = 0;
        for (int i = 1; i <= 100; i++) {
            if (i % 2 == 0) {
                sum2 += i;
            }
        }
        System.out.println("sum2 = " + sum2);


        //求1-1000的偶数个数
        int count = 0;
        for (int i = 1; i <= 1000; i++) {
            if (i % 2 == 0) {
                count++;
            }
        }
        System.out.println("count = " + count);
    }


}
